{include file="public/_meta" /}

<style>

    pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
    .string { color: green; }        /*字符串的样式*/
    .number { color: darkorange; }    /*数字的样式*/
    .boolean { color: blue; }        /*布尔型数据的样式*/
    .null { color: magenta; }        /*null值的样式*/
    .key { color: red; }            /*key值的样式*/

    /*table td {*/
    /*     white-space: normal;*/
    /*}*/

</style>
<body>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}


                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">

                                <form class="row">
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="adv_id" name="adv_id" value="{$adv_id}" placeholder="账户ID">
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="clue_name" name="clue_name" value="{$clue_name}" placeholder="名称">
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="phone" name="phone" value="{$phone}" placeholder="电话">
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="city" name="city" value="{$city}" placeholder="请输入城市">
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <select class="form-control input-full" name="status" id="status">
                                                <option value="">进行状态</option>
                                                <option value="1">已进线</option>
                                                <option value="0">未进线</option>

                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="start_time" id="start_time" value="{$start_time}" placeholder="开始时间" autocomplete="off">
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="end_time" id="end_time" value="{$end_time}" placeholder="结束时间" autocomplete="off">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-3">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <a href="{:url('system/clue_api_log')}" class="btn btn-info" style="color: white;position: absolute;left: 110px;">重置</a>
                                        </div>
                                    </div>
                                </form>

                            </div>
                            <div class="card-body">


                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover">
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>接口名称</th>
                                            <th>线索账户</th>
                                            <th>线索信息</th>
                                            <th>线索内容</th>

                                            <th>时间</th>
                                            <th>是否进线</th>
                                            <th>失败原因</th>
                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="systemLogs" id="vo"}
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.api_url}</td>
                                            <td>
                                                账户ID：【{$vo.adv_id}】<br>
                                                名称：{$vo.acc_name}<br>
                                                简称：{$vo.acc_desc}
                                            </td>
                                            <td>
                                                线索名称：{$vo.name}<br>
                                                线索电话：{$vo.phone}<br>
                                            </td>

                                            <td style="white-space: pre-wrap;" ><div style="width: 1000px;">GET参数：{$vo.param}<br>POST参数：<span name="jsonData[]">{$vo.data}</div></span>

                                            </td>

                                            <td>
                                                {$vo.create_time}</td>

                                            <td>
                                                {if $vo.status == 1}
                                                <span style="color: #2bb930">已进线</span>
                                                {else /}
                                                <span style="color: red">未进线</span>
                                                {/if}
                                            </td>
                                            <td>
                                                {$vo.error}</td>

                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->
                                    <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($systemLogs)}</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>


</div>

{include file="public/_js" /}

</body>
<script>

    $(function (){

        // $.each($("[name='jsonData[]']"),function (index, element) {
        //     console.log(element);
        //     var jsonStr=element.find('span').te;
        //     console.log(jsonStr);
        //
        // })

        $("[name='jsonData[]']").each(function(index,ele){
            // console.log(index);
            // console.log(ele);
            console.log($(this).text());
            $(this).html(syntaxHighlight($(this).text()))
            // $(this).children().eq(1).css('backgroundColor','pink');
        })


        // var jsonData=$("[name='jsonData[]']").text();
        // console.log(jsonData);
    });

    function syntaxHighlight(json) {
        if (typeof json != 'string') {
            json = JSON.stringify(json, undefined, 2);
        }
        json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
        return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
            function(match) {
                var cls = 'number';
                if (/^"/.test(match)) {
                    if (/:$/.test(match)) {
                        cls = 'key';
                    } else {
                        cls = 'string';
                    }
                } else if (/true|false/.test(match)) {
                    cls = 'boolean';
                } else if (/null/.test(match)) {
                    cls = 'null';
                }
                return '<span class="' + cls + '">' + match + '</span>';
            }
        );
    }




    var SCOPE = {
        'item_url':"{:url('system/edit')}",
    };
    laydate.render({
        elem: '#start_time'
        ,type: 'datetime'
    });
    laydate.render({
        elem: '#end_time'
        ,type: 'datetime'
    });

    function edit_item(id)
    {

        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    layer.open({
                        type: 1,
                        area: '500px',
                        content: '<p style="padding: 20px">'+res.data.content+'</p>' //这里content是一个普通的String
                    });
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });


    }

    $('#status').val('{$status}');



</script>

</html>